package com.longge;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-04-27 02:51
 */
public class RangeSumBST {
    int res = 0;

    public int rangeSumBST(TreeNode root, int low, int high) {
        if (root == null) return res;
        rangeSumBST(root.left, low, high);
        if (root.val > high) return res;
        if (root.val >= low) res += root.val;
        rangeSumBST(root.right, low, high);
        return res;
    }

}
